package com.laoye.big_event.Validation;

import com.laoye.big_event.Anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

//ConstraintValidator<给哪个参数提供校验规则,校验的数据类型>
public class StateValidation implements ConstraintValidator<State,String> {
    /**
     *
     * @param value 要校验的数据
     * @param context
     * @return 返回false校验不通过，返回true校验通过
     */

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        //    提供校验规则
        if(value==null){
            return false;
        }
        if(value.equals("已发布")||value.equals("草稿")){
            return true;
        }
        return false;
    }
}
